package team.first.movieapiv2pro.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import team.first.movieapiv2pro.domain.Genre;
import team.first.movieapiv2pro.service.GenreService;
import team.first.movieapiv2pro.vo.ApiResponse;

import java.util.List;

/**
 * @Author: HAPPY
 * @Project_name: project
 * @Package_name: team.first.movieapiv2.controller
 * @Date: 2021/12/9 12:55
 * @Description:
 */
@RestController
public class GenreController {


    @Autowired
    private GenreService genreService;

    /**
     * 2.1 获取全部电影类型信息
     * 接口地址：GET /api/v2/genres
     */
    @ApiOperation("1.1 GET: 获取全部电影类型信息")
    @GetMapping("/api/v2/genres")
    public ApiResponse<List<Genre>> getAllGenres() {
        ApiResponse<List<Genre>> apiResponse = new ApiResponse<>();
        List<Genre> genreList = genreService.list();
        apiResponse.setCode(200).setSuccess(true).setMessage("请求成功").setData(genreList);
        return apiResponse;
    }
}
